<html>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<title>Section 1.4.&nbsp; Requesting Data from a Web Page</title>
<link rel="STYLESHEET" type="text/css" href="images/style.css">
<link rel="STYLESHEET" type="text/css" href="images/docsafari.css">
<script type="text/javascript"><!--
google_ad_client = "pub-0203281046321155";
google_alternate_ad_url = "http://www.bookhtml.com/adbrite.htm";
google_ad_width = 728;
google_ad_height = 90;
google_ad_format = "728x90_as";
google_ad_type = "text_image";
google_ad_channel ="4867465545";
google_color_border = "FFFFFF";
google_color_link = "0000FF";
google_color_bg = "FFFFFF";
google_color_text = "000000";
google_color_url = "0000FF";
//--></script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=learnphpmysql-CHP-1-SECT-3.html><img src="images/prev.gif" width="60" height="17" border="0" align="absmiddle" alt="Previous Page"></a>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=learnphpmysql-CHP-1-SECT-5.html><img src="images/next.gif" width="60" height="17" border="0" align="absmiddle" alt="Next Page"></a>
</div></td></tr></table>
<br><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td valign="top"><a name="learnphpmysql-CHP-1-SECT-4"></a>
<h3 id="title-IDAT1GYH" class="docSection1Title">1.4. Requesting Data from a Web Page</h3>
<p class="docText">How all of these pieces integrate together can be tricky to understand. If a web server detects PHP code, it determines whether the file is a PHP file, and if so, turn over the processing of the page to the PHP interpreter without any additional participation by the web browser. But if you include an external CSS file, your browser issues a separate request for that file before viewing the page.</p>
<a name="learnphpmysql-CHP-1-SECT-4.1"></a>
<h4 id="title-IDA11GYH" class="docSection2Title">1.4.1. PHP Interpretation on the Server</h4>
<p class="docText">This processing of the PHP on the server is called <span class="docEmphasis">server-side processing</span>.<a name="IDX-CHP-1-0037"></a> 
 When you request a web page, you trigger a whole chain of events. <a class="docLink" href="#learnphpmysql-CHP-1-FIG-2">Figure 1-2</a> illustrates this interaction between your computer and the web server (host of the web site).</p>
<a name="learnphpmysql-CHP-1-FIG-2"></a><p><center>
<h5 class="docFigureTitle">Figure 1-2. While the user only types in a URL and hits Enter, there are several steps that occur behind the scenes to handle that request</h5>
<img border="0" alt="" width="549" height="228" SRC="images/learnphpmysql_0102.jpg">
</center></p><br>
<p class="docText">Here's the breakdown of <a class="docLink" href="#learnphpmysql-CHP-1-FIG-2">Figure 1-2</a>:</p>
<div style="font-weight:bold"><ol class="docList" type="1"><LI><div style="font-weight:normal"><p class="docList">You enter a web page address in your browser's location bar.</p></div></li><LI><div style="font-weight:normal"><p class="docList">Your browser breaks apart that address and sends the name of the page to the web server. For example, <a class="docLink" target="_blank" href="http://www.phone.com/directory.html">http://www.phone.com/directory.html</a> would request the page <span class="docEmphasis">directory.html</span> from <a class="docLink" target="_blank" href="http://www.phone.com">www.phone.com</a>.</P></div></li><LI><div style="font-weight:normal"><p class="docList">A program on the web server, called the web server process, takes the request for <span class="docEmphasis">directory.html</span> and looks for this specific file.</p></div></li><li><div style="font-weight:normal"><p class="docList">The web server reads the <span class="docEmphasis">directory.html</span> file from the web server's hard drive.</P></div></li><li><div style="font-weight:normal"><p class="docList">The web server returns the contents of <span class="docEmphasis">directory.html</span> to your browser.</P></div></li><li><div style="font-weight:normal"><p class="docList">Your web browser uses the HTML markup that was returned from the web server to build the rendition of the web page on your computer screen.</P></div></li></ol></div>
<p class="docText">The HTML file called <span class="docEmphasis">directory.html</span> (requested in <a class="docLink" href="#learnphpmysql-CHP-1-FIG-2">Figure 1-2</a>) is called a <span class="docEmphasis">static web page</span>. It is static because everyone who requests the <span class="docEmphasis">directory.html</span> page gets exactly the same page.</p>
<p class="docText">For the web server to customize the returned page, PHP and MySQL are added to the mix. <a class="docLink" href="#learnphpmysql-CHP-1-FIG-3">Figure 1-3</a> illustrates the extra steps that occur in the chain of events on the web host.</p>
<a name="learnphpmysql-CHP-1-FIG-3"></a><p><center>
<H5 class="docFigureTitle">Figure 1-3. The PHP interpreter, MySQL, and the web server cooperate to return the page</H5>
<img border="0" alt="" width="549" height="223" SRC="images/learnphpmysql_0103.jpg">
</center></p><br>
<p class="docText">Each step in the chain is listed here:</p>
<div style="font-weight:bold"><ol class="docList" type="1"><li><div style="font-weight:normal"><p class="docList">You enter a web page address in your browser's location bar.</P></div></li><LI><div style="font-weight:normal"><p class="docList">Your browser breaks apart that address and sends the name of the page to the host. For example, <a class="docLink" target="_blank" href="http://www.phone.com/login.php">http://www.phone.com/login.php</a> requests the page <span class="docEmphasis">login.php</span> from <a class="docLink" target="_blank" href="http://www.phone.com">www.phone.com</a>.</p></div></LI><LI><div style="font-weight:normal"><p class="docList">The web server process on the host receives the request for <span class="docEmphasis">login.php</span>.</P></div></li><li><div style="font-weight:normal"><p class="docList">The web server reads the <span class="docEmphasis">login.php</span> file from the host's hard drive.</p></div></li><li><div style="font-weight:normal"><p class="docList">The web server detects that the PHP file isn't just a plain HTML file, so it asks another processthe PHP interpreterto process the file.</p></div></li><li><div style="font-weight:normal"><p class="docList">The PHP interpreter executes the PHP code that it finds in the text it received from the web server process. Included in that code are calls to the MySQL database.</p></div></li><li><div style="font-weight:normal"><p class="docList">PHP asks the MySQL database process to execute the database calls.</p></div></li><li><div style="font-weight:normal"><p class="docList">The MySQL database process returns the results of the database query.</P></div></li><li><div style="font-weight:normal"><p class="docList">The PHP interpreter completes execution of the PHP code with the data from the database and returns the results to the web server process.</P></div></LI><li><div style="font-weight:normal"><p class="docList">The web server returns the results in the form of HTML text to your browser.</P></div></li><li><div style="font-weight:normal"><p class="docList">Your web browser uses the returned HTML text to build the web page on your screen.</p></div></LI></ol></div>
<p class="docText">This may seem like a lot of steps, but all of this processing happens automatically every time a web page with PHP code is requested.</p>
<p class="docText">When developing dynamic web pages, you work with a variety of variables and server components, which are all important to having an attractive, easy to navigate, and maintainable web site. Next, it's time to install the three major cogs needed to make this work: Apache, PHP, and MySQL.</p>


<a href="11011536.html"><img src="images/pixel.jpg" alt="" width="1" height="1" border="0"></a></TD></TR></table>
<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=learnphpmysql-CHP-1-SECT-3.html><img src="images/prev.gif" width="60" height="17" border="0" align="absmiddle" alt="Previous Page"></a>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=learnphpmysql-CHP-1-SECT-5.html><img src="images/next.gif" width="60" height="17" border="0" align="absmiddle" alt="Next Page"></a>
</div></td></tr></table>
</body></html>
